package com.minshenglife.zanzan.service.power.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.minshenglife.zanzan.dao.power.ManagerEmpDao;
import com.minshenglife.zanzan.entity.power.ManagerEmp;
import com.minshenglife.zanzan.entity.power.ManagerList;
import com.minshenglife.zanzan.service.power.ManagerEmpService;

@Component
@Transactional
public class ManagerEmpServiceImpl implements ManagerEmpService {
	Logger log = LoggerFactory.getLogger(ManagerEmpServiceImpl.class);

	@Resource
	ManagerEmpDao managerEmpDao;

	@Override
	public ManagerEmp findMangerEmp(String userName, String password) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("empId", userName);
		map.put("passWord", password);
		ManagerEmp managerEmp = managerEmpDao.findManagerEmp(map);
		return managerEmp;
	}

	@Override
	public void insertManagerEmp(ManagerEmp manager) {
		manager.setGrade("0");
		managerEmpDao.add(manager);
	}

	@Override
	public String finddet_name(String dept_id) {
		if("586".equals(dept_id)){
			return "总公司";
		}
		return managerEmpDao.findDept_name(dept_id);
	}

	@Override
	public ManagerEmp findId(String empId) {
		return managerEmpDao.findId(empId);
	}

	@Override
	public void deleteManager(String empId) {
		managerEmpDao.deleteManager(empId);
	}

	@Override
	public void updateManger(String passWord,String empId) {
		Map<String, Object> map = new HashMap<String ,Object>();
		map.put("passWord", passWord);
		map.put("empId",empId);
		managerEmpDao.updatePassWord(map);
	}

	@Override
	public List<ManagerList> getManagerList() {
		return managerEmpDao.getManagerList();
	}

}
